<div class="row-fluid">
    <div class="span12">
        <div>
            <p class="nav-header">Actions</p>
            <ul class="nav nav-tabs">
                <li><a href="<?php echo $this->Html->url('add/');?>">New Company</a></li>
            </ul>
        </div>
    </div>
</div>
<?php $paginator = $this->Paginator; ?>
<div class="row-fluid">
    <div class="span12">
        <?php echo $this->element('message'); ?>   
        <div class="page-header">
            <h1>Companies</h1>
        </div>
        <table class="table table-bordered table-striped">
        <!-- <table class="datagrid"> -->
            <thead>
                <tr>
                    <th><?php echo $paginator->sort('id', 'ID') ?></th>
                    <th><?php echo $paginator->sort('name', 'Name') ?></th>
                    <th><?php echo $paginator->sort('short_description', 'Short Description') ?></th>                    
                    <th><?php echo $paginator->sort('order', 'Order') ?></th>                    
                    <th>Status</th>
                    <th colspan="2">Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($rows as $row) {
                    $rd_id = rand(1000000000, 9999999999);
                    echo "<tr>";
                    echo "<td>{$row['Company']['id']}</td>";
                    echo "<td>{$row['Company']['name']}</td>";
                    echo "<td>{$row['Company']['short_description']}</td>";
                    echo "<td>{$row['Company']['order']}</td>";
                    echo "<td>{$row['Company']['status']}</td>";
                    echo "<td>{$this->Html->link(__('Edit'), array('action' => 'edit', $row['Company']['id']), array('class' => 'btn btn-warning'))}</td>";
                    echo "<td><form action=\"{$this->Html->url('delete/' . $row['Company']['id'])}\" name=\"post_{$rd_id}\" id=\"post_{$rd_id}\" style=\"display:none;\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"POST\"></form>{$this->Html->link(__('Delete'), '#', array('class' => 'btn btn-danger', 'onclick' =>'if (confirm( \'Are you sure you want to delete #'.$row["Company"]["id"].'\')) {document.post_'.$rd_id.'.submit(); } event.returnValue = false; return false;'))}</td>";
                    echo "</tr>";
                }
                ?>
            </tbody>
        </table>

        <div class="pagination">
            <ul>
                <?php
                echo '<li>' . $paginator->first("First") . '</li>';
                if ($paginator->hasPrev()) {
                    echo '<li>' . $paginator->prev("Prev") . '</li>';
                }
                // the 'number' page buttons
                echo $paginator->numbers(array('modulus' => 3, 'tag' => 'li', 'separator' => '', 'currentTag' => 'a', 'currentClass' => 'active'));

                // for the 'next' button
                if ($paginator->hasNext()) {
                    echo '<li>' . $paginator->next("Next") . '</li>';
                }
                // the 'last' page button
                echo '<li>' . $paginator->last("Last") . '</li>';
                ?>
            </ul>
        </div>
    </div>
</div>
